<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <title>添加事件 - 个人记事系统</title>
    <meta charset="UTF-8">
    <style>
        body {
            background: linear-gradient(120deg, #fdfbfb 0%, #ebedee 100%);
            font-family: 'Microsoft YaHei', sans-serif;
            margin: 0;
            padding: 20px;
            min-height: 100vh;
        }
        .form-container {
            max-width: 800px;
            margin: 30px auto;
            padding: 30px;
            background: white;
            border-radius: 15px;
            box-shadow: 0 10px 25px rgba(0,0,0,0.05);
        }
        .form-group {
            margin-bottom: 25px;
        }
        .form-group label {
            display: block;
            margin-bottom: 10px;
            color: #333;
            font-weight: 500;
            font-size: 16px;
        }
        .form-group input[type="text"],
        .form-group input[type="date"],
        .form-group textarea {
            width: 100%;
            padding: 12px;
            border: 2px solid #e1e1e1;
            border-radius: 8px;
            font-size: 16px;
            transition: all 0.3s ease;
            box-sizing: border-box;
        }
        .form-group textarea {
            height: 150px;
            resize: vertical;
            font-family: inherit;
        }
        .form-group input[type="file"] {
            width: 100%;
            padding: 10px;
            background: #f8f9fa;
            border: 2px dashed #dee2e6;
            border-radius: 8px;
            cursor: pointer;
        }
        .btn {
            padding: 12px 25px;
            font-size: 16px;
            font-weight: 500;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
            margin-left: 10px;
        }
        .btn-primary {
            background: linear-gradient(45deg, #4CAF50, #45a049);
            color: white;
        }
        .btn-cancel {
            background: linear-gradient(45deg, #ff4b4b, #ff3333);
            color: white;
        }
        .btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        }
        .file-preview {
            margin-top: 15px;
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
            gap: 15px;
        }
        .file-preview img {
            width: 100%;
            height: 150px;
            object-fit: cover;
            border-radius: 8px;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        }
        .file-preview p {
            padding: 10px;
            background: #f8f9fa;
            border-radius: 5px;
            margin: 5px 0;
            font-size: 14px;
        }
        h2 {
            color: #333;
            text-align: center;
            margin-bottom: 30px;
            font-size: 28px;
        }
        .buttons-container {
            text-align: right;
            margin-top: 30px;
        }
    </style>
</head>
<body>
    <div class="form-container">
        <h2>添加新事件</h2>
        
        <form action="event" method="post" enctype="multipart/form-data">
            <div class="form-group">
                <label for="title">标题</label>
                <input type="text" id="title" name="title" required 
                       placeholder="请输入事件标题">
            </div>
            
            <div class="form-group">
                <label for="description">描述</label>
                <textarea id="description" name="description" required 
                          placeholder="请输入事件详细描述"></textarea>
            </div>
            
            <div class="form-group">
                <label for="eventDate">日期</label>
                <input type="date" id="eventDate" name="eventDate" required>
            </div>

            <div class="form-group">
                <label for="files">上传文件</label>
                <input type="file" id="files" name="files" multiple 
                       accept="image/*,.txt,.doc,.docx,.pdf,.xls,.xlsx" onchange="previewFiles(this)">
                <div id="filePreview" class="file-preview"></div>
            </div>
            
            <div class="buttons-container">
                <a href="dashboard.jsp" class="btn btn-cancel">取消</a>
                <button type="submit" class="btn btn-primary">保存</button>
            </div>
        </form>
    </div>

    <script>
    function previewFiles(input) {
        var preview = document.getElementById('filePreview');
        preview.innerHTML = '';
        
        for(var i = 0; i < input.files.length; i++) {
            var file = input.files[i];
            if(file.type.startsWith('image/')) {
                var reader = new FileReader();
                reader.onload = function(e) {
                    var img = document.createElement('img');
                    img.src = e.target.result;
                    preview.appendChild(img);
                }
                reader.readAsDataURL(file);
            } else {
                var p = document.createElement('p');
                p.textContent = '文件: ' + file.name;
                var icon = document.createElement('span');
                icon.className = 'file-icon';
                // 根据文件类型显示不同图标
                if(file.name.endsWith('.pdf')) {
                    icon.textContent = '📄 PDF';
                } else if(file.name.match(/\.docx?$/)) {
                    icon.textContent = '📝 Word';
                } else if(file.name.match(/\.xlsx?$/)) {
                    icon.textContent = '📊 Excel';
                } else if(file.name.endsWith('.txt')) {
                    icon.textContent = '📝 Text';
                } else {
                    icon.textContent = '📎';
                }
                p.insertBefore(icon, p.firstChild);
                preview.appendChild(p);
            }
        }
    }
    </script>
</body>
</html> 